import * as Pinia from 'pinia';
import {
    createPersistedState
} from 'pinia-plugin-persistedstate'

export const pinia = Pinia.createPinia()

export const store = (app) => {
    pinia.use(
        createPersistedState({
            storage: {
                getItem(key) {
                    return uni.getStorageSync(key)
                },
                setItem(key, value) {
                    uni.setStorageSync(key, value)
                },
            },
        }),
    )
    app.use(pinia)
}